#include <iostream>
#include <cstring>
using namespace std;
int a[51][51],dp[51][51][51][51];
int main(){
	int n,m;
	cin>>n>>m;
	memset(dp,0,sizeof(dp));
	for(int i = 1;i<=n;++i)
		for(int j = 1;j<=m;++j)
		cin>>a[i][j];
	for(int i = 1;i<=n;++i){
		for(int j = 1;j<=m;++j){
			for(int k = 1;k<=n;++k){
				for(int l = 1;l<=m;++l){
					if(i+j==k+l){
						if(i==k&&j==l)
							continue;
						dp[i][j][k][l] = max(max(dp[i-1][j][k-1][l],dp[i-1][j][k][l-1]),max(dp[i][j-1][k-1][l],dp[i][j-1][k][l-1]))+a[i][j]+a[k][l];
						
					}
				}
			}
		}
	}cout<<max(max(dp[n-1][m][n-1][m],dp[n-1][m][n][m-1]),max(dp[n][m-1][n-1][m],dp[n][m-1][n][m-1]));
	return 0;
	
}